#pragma once

namespace Tmpl {

#define DEPENDENCY_NONE -1

typedef void* HANDLE;
typedef int JobHandle;
class JobManager
{
public:
	static void Init( int threadcount );
	static void Exit( );

	static JobHandle NewJob( );
	static JobHandle NewJob( void(*threadfunc)() );
	static JobHandle NewJob( void(*threadfunc)(int), int i1 );
	static JobHandle NewJob( void(*threadfunc)(int, int), int i1, int i2 );
	static JobHandle NewJob( void(*threadfunc)(int, int, int), int i1, int i2, int i3 );
	static JobHandle NewJob( void(*threadfunc)(void*, int), void* data, int i1 );
	static JobHandle NewJob( void(*threadfunc)(void*, int, int), void* data, int i1, int i2 );
	static JobHandle NewJob( void(*threadfunc)(void*, void*, int, int), void* data1, void* data2, int i1, int i2 );

	static void AddJobDependency( JobHandle job, JobHandle dependency );
	static void AddExecuteJob( JobHandle job );
	static bool IsJobDone( JobHandle handle );
	static void WaitForJobsToFinish();

	static JobHandle SetAnEventJob(HANDLE eventHandle, int reset=false);

	static int GetJobCount();
	static int GetThreadCount();
};

} // namespace Tmpl